package com.dyh.quickdemo.bizDemo.concM;

import org.junit.jupiter.api.Test;

import java.util.concurrent.ConcurrentLinkedQueue;

/*
@Author=Joey Wheeler
@Date=2021/3/2 11:13
*/
public class ConcM {

    public ConcurrentLinkedQueue concurrentLinkedQueue = new ConcurrentLinkedQueue();



    @Test
    public void test() throws InterruptedException {
        new Thread(()->
        {
            for (;;){
               // System.out.println("add");
                try {
                    Thread.sleep(500L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                concurrentLinkedQueue.add("111");
            }
            }
            ).start();

        new Thread(()->{
            for (;;){
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("size");
                System.out.println(concurrentLinkedQueue.size());
            }
        }).start();


        Thread.sleep(30*1000);
    }
}
